package com.langfeiyes.pattern.prototype;

public class Emp implements  Cloneable{
    private String name;
    private Dept dept;

    public Emp(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Dept getDept() {
        return dept;
    }
    public void setDept(Dept dept) {
        this.dept = dept;
    }
    @Override
    public String toString() {
        return "Emp{" +
                "name='" + name + '\'' + ", hashcode:" + this.hashCode() +
                ", dept=" + dept +
                '}';
    }
    @Override
    protected Object clone() throws CloneNotSupportedException {
        Emp emp = (Emp) super.clone();
        Dept dept  = (Dept) emp.getDept().clone();
        emp.setDept(dept);
        return emp;
    }
}
